package com.xms.sdk.core.query;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * <p>
 * FilterExpression
 * </p>
 *
 * @author migo
 * @since 2021/9/1
 */
public class FilterExpression implements Serializable {

    public LogicalOperator FilterOperator = LogicalOperator.And;

    public List<ConditionExpression> Conditions = new ArrayList<>();

    public List<FilterExpression> Filters = new ArrayList<>();

    public FilterExpression()
    {
    }

    public FilterExpression(LogicalOperator filterOperator)
    {
        this.FilterOperator = filterOperator;
    }

    public FilterExpression addCondition(String attributeName, int conditionOperator, Object... values)
    {
        this.Conditions.add(new ConditionExpression(attributeName, conditionOperator, values));
        return this;
    }

    public FilterExpression addCondition(String attributeName, int conditionOperator, UUID... values)
    {
        this.Conditions.add(new ConditionExpression(attributeName, conditionOperator, values));
        return this;
    }

    /*public FilterExpression addCondition(String attributeName, int conditionOperator, int... values)
    {
        this.Conditions.add(new ConditionExpression(attributeName, conditionOperator, values));
        return this;
    }*/

    public FilterExpression addCondition(String attributeName, int conditionOperator, String... values)
    {
        this.Conditions.add(new ConditionExpression(attributeName, conditionOperator, values));
        return this;
    }

    public FilterExpression addCondition(String attributeName, int conditionOperator)
    {
        this.Conditions.add(new ConditionExpression(attributeName, conditionOperator));
        return this;
    }

    public FilterExpression addCondition(ConditionExpression condition)
    {
        if (condition != null)
        {
            this.Conditions.add(condition);
        }
        return this;
    }

    public FilterExpression addFilter(FilterExpression childFilter)
    {
        if (childFilter != null)
        {
            this.Filters.add(childFilter);
        }
        return this;
    }
}
